package com.liuxn.dubbo.sample.demo.config;

import com.liuxn.dubbo.sample.demo.util.xss.XSSFilter;
import com.yomahub.tlog.web.filter.TLogServletFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;

/**
 * @author liuxn
 * @date 2024/10/10
 */
@Configuration
public class WebConfig {

    /**
     * tlog 链路追踪
     *
     * @return
     */
    @Bean
    public FilterRegistrationBean tLogFilter() {
        FilterRegistrationBean<TLogServletFilter> bean = new FilterRegistrationBean<TLogServletFilter>();
        bean.setFilter(new TLogServletFilter());
        bean.addUrlPatterns("/*");
        bean.setOrder(Ordered.HIGHEST_PRECEDENCE + 1);
        return bean;
    }

    // /**
    //  * token 验证
    //  *
    //  * @return
    //  */
    // @Bean
    // public FilterRegistrationBean tokenFilter() {
    //     FilterRegistrationBean<TokenFilter> bean = new FilterRegistrationBean<TokenFilter>();
    //     bean.setFilter(new TokenFilter());
    //     bean.addUrlPatterns("/*");
    //     bean.setOrder(Ordered.HIGHEST_PRECEDENCE + 2);
    //     return bean;
    // }

}
